﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace WindowsGame1
{
    class StateShoot : State
    {
        public float delayMin = 1;
        public float delayMax = 1;
        public Vector2 dirMin = new Vector2(0, 0);
        public Vector2 dirMax = new Vector2(0, 0);

        public float timeLeftUntilNextShoot = 0;    

        public StateShoot(Alien alien)
            : base(alien)
        {

        }

        public override bool Update(Timer t)
        {
            timeLeftUntilNextShoot -= t.Delta;
            if (timeLeftUntilNextShoot < 0)
            {
                timeLeftUntilNextShoot = MathHelper.Lerp(delayMin, delayMax, Game1.instance.RndFloat());

                float r = Game1.instance.RndFloat();
                alien.OnEventShoot( dirMin * r + dirMax * (1 - r) );
            }
            return true;
        }
    }
}
